﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using FTBS.Models.DAO;
using FTBS.Models.Entities;

namespace FTBS.Models.BLO
{
    public class PriceTicketBLO
    {

        private PriceTicketDAO _priceTicketDao = new PriceTicketDAO();
        private TicketBLO _ticketBlo = new TicketBLO();

        public double GetPriceTicket(int theaterId, int chairTypeId)
        {
            return _priceTicketDao.GetPriceTicket(theaterId, chairTypeId);
        }

        public int GetPriceTicketId(int theaterId, int chairTypeId)
        {
            return _priceTicketDao.GetPriceTicketId(theaterId, chairTypeId);
        }

        public PriceTicket GetPriceTicketById(int id)
        {
            return _priceTicketDao.GetPriceTicketById(id);
        }

        /// <summary>
        /// Insert List PriceTicket
        /// </summary>
        /// <param name="listPriceTicket"></param>
        /// <returns></returns>
        public bool CreatePriceTicket(List<PriceTicket> listPriceTicket)
        {
            var result = _priceTicketDao.Add(listPriceTicket);
            if (result > 0)
            {
                return true;
            }
            else
            {
                return false;
            }
        }

        //public bool CreatePriceTicket(PriceTicket pt)
        //{
        //    var result = _priceTicketDao.Add(pt);
        //    if (result == 1)
        //    {
        //        return true;
        //    }
        //    else
        //    {
        //        return false;
        //    }
        //}

        public bool EditPriceTicket(List<PriceTicket> priceTickets)
        {
            var result = _priceTicketDao.Edit(priceTickets);
            if (result > 0)
            {
                return true;
            }
            else
            {
                return false;
            }
        }

        public bool EditBoughtPriceTickets(List<PriceTicket> priceTickets)
        {
            var result = _priceTicketDao.Edit(priceTickets);
            if (result > 0)
            {
                return true;
            }
            else
            {
                return false;
            }
        }
        
        public bool DeletePriceTicket(int priceTicketId)
        {
            var result = _priceTicketDao.DeletePriceTicket(priceTicketId);
            if (result == 1)
            {
                return true;
            }
            else
            {
                return false;
            }
        }

        public bool CheckIsExistedPriceTicket(int theaterId)
        {
            var result = _priceTicketDao.CheckIsExistedPriceTicket(theaterId);
            if (result > 0)
            {
                return true;
            }
            else
            {
                return false;
            }
        }

        /// <summary>
        /// Check the ShowTimeId is used in Schedule or not
        /// This function is used for user Click to Delete in List ShowTIme
        /// </summary>
        /// <param name="showTimeId"></param>
        /// <returns>True: Is Exist ---- False: Not Exist</returns>
        /// <author>VuongVT</author>
        public bool IsPriceTicketUsedForSchedule(PriceTicket priceTicket)
        {
            return _priceTicketDao.IsPriceTicketUsedForSchedule(priceTicket);
        }

    }
}